﻿namespace Chaliy.Syndication.UnitTests.MediaRss
{
    using System.Xml.XPath;
    using Xunit;
    using System.Runtime.Serialization;

    internal static class MediaAssertionExtensions
    {
        public static XPathNavigator ShouldMatchMedia(this object serializable, string xPath, string message)
        {
            return new ElementSerializer(serializable)
                .Serialize()            
                .ShouldMatch(xPath, 
                    "media", "http://search.yahoo.com/mrss/", message);
        }

        public static void ShouldNotMatchMedia(this object serializable, string xPath, string message)
        {
            new ElementSerializer(serializable)
                .Serialize()
                .ShouldNotMatch(xPath,
                    "media", "http://search.yahoo.com/mrss/", message);
        }

        public static void ShouldThrowSerializationException(this object serializable)
        {
            Assert.Throws(typeof(SerializationException),
                () => new ElementSerializer(serializable).Serialize());            
        }
    }
}
